package day11.HashSet.linkedHashSet;

import heima.FangXing.day10.domain.Student;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class CollectionsDemo1 {
    public static void main(String[] args) {
        ArrayList<String> arr = new ArrayList<>();
        Collections.addAll(arr,"a","b","c","d");
        System.out.println(arr);
        //二分查找（前提：排好序）
        System.out.println(Collections.binarySearch(arr, "b"));


        //洗牌
        Collections.shuffle(arr);
        System.out.println(arr);

//        Collections.swap("a","d");

        ArrayList<Student> list = new ArrayList<>();
        Collections.addAll(list,new Student("张三",23),new Student("李四",24), new Student("王五",25));
        System.out.println(Collections.max(list));
        System.out.println(Collections.min(list));

        //交换
        Collections.swap(list,0,2);
        System.out.println(list);

        //sort:排序
        ArrayList<Integer> list2 = new ArrayList<>();
        Collections.addAll(list2,1,2,6,4,5);
        Collections.sort(list2, (o1, o2) -> o2 - o1);
        System.out.println(list2);


    }
}
